export class Storage {
  static get(key: string): any {
    const res = localStorage.getItem(key);
    return res ? JSON.parse(res) : null;
  }

  static set(key: string, value: any) {
    localStorage.setItem(key, JSON.stringify(value));
  }

  static has(key: string) {
    return localStorage.hasOwnProperty(key);
  }

  static getFormatObj(key: string) {
    const res = localStorage.getItem(key);
    return res ? JSON.parse(res).reduce((pre, cur) => ({ ...pre, cur: true }), {}) : null;
  }

  static clear() {
    localStorage.clear();
  }
}
